from apps.resume.models import UserBaseInfo, ExpectWork, WorkExp, ProjectExp, EduBkGround, SelfDesc, ProductionShow


def query_resume(user_id):
    # 用户基本信息
    try:
        base_info = UserBaseInfo.objects.get(user_id=user_id)
    except:
        base_info = None
    # print(base_info.head_image)
    # 用户期待工作
    try:
        expect_work = ExpectWork.objects.get(user_id=user_id)
    except:
        expect_work = None

    # 用户工作经历
    try:
        work_exp = WorkExp.objects.get(user_id=user_id)
    except:
        work_exp = None

    # 用户项目经验
    try:
        pro_exp = ProjectExp.objects.get(user_id=user_id)
    except:
        pro_exp = None

    # 用户教育背景
    try:
        edu_bk = EduBkGround.objects.get(user_id=user_id)
    except:
        edu_bk = None

    # 自我描述
    try:
        self_desc = SelfDesc.objects.get(user_id=user_id)
    except:
        self_desc = None

    # 作品展示
    try:
        production = ProductionShow.objects.get(user_id=user_id)
    except:
        production = None

    content = {
        "base_info": base_info,  # 用户基本信息
        "expect_work": expect_work,  # 用户期待工作
        "work_exp": work_exp,  # 用户工作经历
        "pro_exp": pro_exp,  # 用户项目经验
        "edu_bk": edu_bk,  # 用户教育背景
        "self_desc": self_desc,  # 用户自我描述
        "production": production,  # 用户作品展示
    }

    return content
